import { mapState, createNamespacedHelpers } from 'vuex';
import { useMapper } from './useMapper'

export function useState(moduleName, mappr) {
    let mapperFn = mapState
    if (typeof moduleName === "string" && moduleName.length > 0) {
        mapperFn = createNamespacedHelpers(moduleName).mapState
    }
    return useMapper(mappr, mapperFn)
}